package com.yn.pet.controller.app;

import com.yn.common.annotation.Anonymous;
import com.yn.pet.controller.tcpserver.PetServer808Service;
import com.yn.pet.entity.T8103;
import com.yn.pet.protocol.t808.T0001;

import com.yn.pet.server.commons.model.APIResult;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/test")
public class TestDeviceController {

    private final PetServer808Service petServer808Service;

    @Anonymous
    @GetMapping("/t8103")
    public void testT8103() {
        T8103 t8103 = new T8103();
        Map<Integer, Object> parameters = new HashMap<>();
        parameters.put(1, "1");
        t8103.addParameter(1, "1");
        t8103.setParameters(parameters);
        petServer808Service.T8103(t8103);
//        Mono<APIResult<T0001>> apiResultMono = petServer808Service.T8103(t8103)
//                .onErrorResume(error -> {
//                    log.error("调用出现异常: {}", error.getMessage(), error);
//                    return Mono.error(error); // 重新抛出异常以触发熔断
//                });
//        apiResultMono.subscribe(
//                success -> log.info("调用成功: {}", success),
//                error -> log.error("调用失败: {}", error.getMessage(), error)
//        );
    }
}
